\section*{Run 5}
\subsection*{Modules to decompose}
The module we are going to decompose in this run is Other Functionality.

\subsection*{Choose architectural drivers}
\begin{itemize}
\item New requirement number 1: Landlord/janitor in apartment buildings
\item New requirement number 3: Third party fraud detection
\item M2: Fine grained metering
\item M3: Decentralizing electricity generation
\item UC1: Log in
\item UC2: Log off
\item UC3: Register customer
\item UC4: Unregister customer
\item UC5: Associate device to customer
\item UC6: Customize customer profile
\item UC11: Operate actuator remotely
\item UC12: Set alarm recipients
\item UC17: Perform research
\end{itemize}

This is the final ADD run where we add all the functionality that is not yet implemented.

\subsection*{Choose architectural patterns}

Modifiability tactics:
\begin{itemize}
\item Generalize the module. Throughout all ADD runs we tried to make the interfaces as general and abstract as possible, making sure not to go too abstract. For example storing data in the database is dependent on the query that is provided. This allows for the creation of new queries.
\item Anticipate expected changes (M3): For M3 the database can already hold a record for the production of electricity. For users that do not produce electricity, this record is empty. Customers that do produce electricity can use this record for storing their production. 
\end{itemize}

%Patterns
%\begin{itemize}
%\item 
%\end{itemize}

\subsection*{Modules}

\begin{itemize}
\item Fraud Detection: This component send the measurement data in batch to the Third Party Fraud Detection. When fraud has been detected, the Third Party Fraud Detection Service can let ReMes know. This Component will then send an issue notification to a ReMeS operator.
\item Customer Portal: This is the web interface for the customer. If the person is not yet a customer, he has the ability to register. When a person is already a customer he has the ability to log in and off, to check relevant data from his account and to personalize his account (e.g. Add alarm recipients, change between static and dynamic pricing, ...).
\item Operator Portal: This is the portal where the operator/technician must log in. The technician has the ability to connect a new user with a new device (or multiple devices).% The operator has an interface to adjust all kinds of stuff to the database.
\item Researcher Portal: The researcher can use this portal to get statistics and to perform queries to the database.
\item Statistics: This component allows users to get specific statistics from the database.
\end{itemize}

\begin{figure}
  \centering
    \includegraphics[width=\textwidth]{addRuns/ADDRun5_1.pdf}
  \caption{Run 5: First part of level 2 and level 3 decomposition of the ReMeS system}
  \label{addRun5.1}
\end{figure}

\begin{figure}
  \centering
    \includegraphics[width=\textwidth]{addRuns/ADDRun5_2.pdf}
  \caption{Run 5: Second part of level 2 and level 3 decomposition of the ReMeS system}
  \label{addRun5.2}
\end{figure}

\subsection*{Define interfaces}

\begin{center}
    \begin{longtable}{ | p{4cm} | p{3,5cm} | p{7,5cm} |}
    \hline
    Component & Interface & Operations \\ \hline
    Fraud Detection & iFraudDetection & \begin{itemize} \item \textbf{fraudDetected(FraudInfo f)} \end{itemize}  \\ \hline
    Customer Portal & iCustomerPortal & \begin{itemize} \item \textbf{login(Credentials c)} \item \textbf{register(Info i)} \item \textbf{unregister(Customer c)} \item \textbf{customizeProfile(Info i)} \item \textbf{getAccountInfo()} \end{itemize}  \\ \hline
    Operator Portal & iOperatorPortal & \begin{itemize} \item \textbf{login(Credentials c)} \item \textbf{linkDevice(Customer c, Device d)} \item \textbf{register(Info i)} \item \textbf{unregister(Customer c)} \end{itemize}     \\ \hline
	Researcher Portal & iResearcherPortal & \begin{itemize} \item \textbf{login(Credentials c)} \item \textbf{getStatistics(Query q)} \end{itemize}	   \\ \hline
	Statistics & iStatistics & \begin{itemize} \item \textbf{getStatistics()} \item \textbf{getStatistics(Query q)} \end{itemize}	  \\ \hline
	Command Sender & iCommandSender & \begin{itemize} \item actuateValve(Module m) \item processConfirmTrame(Trame t) \item sendAck(Module m, Trame t) \item updatePrice(Customer c, Price p) \item \textbf{reconfigure(Module m, Configuration c)}\end{itemize} \\ \hline
	Notification DB & iNotificationDB & \begin{itemize} \item readNotificationData(Module m) \item \textbf{updateNotificationData(Module m, Data d)} \end{itemize}  \\ \hline    
    \end{longtable}
\end{center}

\begin{itemize}
\item The Customer Portal has a few different interfaces. Register and unregister must be possible and also looking up their measurement data and customizing their profile.
\item The Fraud Detection component offers the ability to send measurements to the Fraud Detection Service and to notify ReMeS of cases of fraud.
\item The Statistics component offers 2 interfaces, but one of them is only available to the researcher, because the researcher needs to be able to perform specific queries on the database. The Statistics component takes care of the layout of the data it gets from the database.
\end{itemize} 

\begin{figure}[]
  \centering
    \includegraphics[width=\textwidth]{addRuns/Run5.png}
  \caption{Run 5: The addition of the Fraud Detection, Customer Portal, Operator Portal, Researcher Portal and Statistics components to the second level decomposition}
  \label{run5}
\end{figure}

\subsection*{Verify and refine}
\begin{itemize}
\item The New requirement of fraud detection is completed. Every now and then a batch of measurement data is send to the Third Party Fraud Detection Service and they can let ReMeS know if someone is committing fraud.
\item The requirement with the landlord/janitor can be seen as an extension of the fine grained metering. Both requirements include that a customer has multiple remote modules under their command. This can just be added in the database. With the landlord/janitor requirement there is also the fact that a remote module can have a customer and a landlord. This extension is just another new record in the database.
\item M3 is also a data solution. By adding a new record in the database, the ability to produce electricity can be stored.
\item Customer interaction is controlled by the customer portal. We did not go into depth in this component, but obviously authentication and authorization control is needed for the customers, to make sure they are logged in and can only access their own account information. So this basically covers UC1 - UC6. In this portal users must be able to actuate their valves and being able to adjust their alarm recipient data.
\item Researchers have a private portal where also a form of access control is needed, to make sure only researchers can perform specific queries on the database.
\end{itemize}


\paragraph*{Requirements that are now completely covered:}
\begin{itemize}
\item Av1: Measurement database failure
\item Av2: Missing measurements
\item Av3: Third Party Billing Service failure
\item P1: Timely closure of valves
\item P2: Anomaly Detection
\item P3: Requests to the measurement database
\item M1: Dynamic pricing
\item \textbf{M2: Fine-grained metering}
\item \textbf{M3: Decentralized electricity generation}
\item \textbf{UC1: Log in}
\item \textbf{UC2: Log off}
\item \textbf{UC3: Register customer}
\item \textbf{UC4: Unregister customer}
\item \textbf{UC5: Associate device to customer}
\item \textbf{UC6: Customize customer profile}
\item UC7: Send trame to remote device
\item UC8: Send measurement
\item UC9: Notify customer
\item UC10: Detect anomaly
\item \textbf{UC11: Operate actuator remotely}
\item \textbf{UC12: Set alarm recipients}
\item UC13: Send alarm
\item UC14: Request consumption predictions
\item UC15: Generate invoice
\item UC16: Mark invoice paid
\item \textbf{UC17: Perform research}
\item \textbf{New requirement number 1: Landlord/janitor in apartment buildings}
\item \textbf{New requirement number 3: Third party fraud detection}
\end{itemize}


%\subsection*{Remarks}
%\begin{itemize}
%\end{itemize}